using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using webapp4U.BOL;


namespace webapp4U.UI.Control
{
    public partial class Contact : System.Web.UI.UserControl
    {
        private int ContactID;
        private int CateID = -1;
        protected void Page_Load(object sender, EventArgs e)
        {
            ContactID = Convert.ToInt32(Request.QueryString["ContactID"]);
            CateID = Convert.ToInt32(Request.QueryString["CateID"]);

            System.Threading.Thread.Sleep(1000);
            if (!Page.IsPostBack)
            {
                webapp4U.BOL.Contact obj = webapp4U.BOL.Contact.GetContactByID(ContactID);
                lblFullName.Text = obj.FullName;
                lblAddress.Text = obj.Address;
                lblTel.Text = obj.Tel;
                lblEmail.Text = obj.Email;
                lblPostDate.Text = obj.AddedDate.ToString();
                lblTitle.Text = obj.Title;
                lblContent.Text = obj.Content;
            }

            btDelete.OnClientClick = "if (confirm('Are you sure you want to delete this post?') == false) return false;";
        }

        protected void btDelete_Click(object sender, EventArgs e)
        {
            webapp4U.BOL.Contact.Delete(ContactID);
            Response.Redirect(Globals.ApplicationPath + "WebMaster/Contacts/Contact.aspx");
        }

    }
}